<template>
  <div>
    <h3>{{ question.text }}</h3>
    <a-radio-group>
      <span
          v-for="option in question.options"
          :key="option.value"
          :value="option.value"
      >
        <a-radio>{{ option.text }}
          <span style="color: red">{{getJumpInfo(option.value)}}</span>
        </a-radio>
      </span>

    </a-radio-group>
  </div>
</template>

<script setup>
import { defineProps} from 'vue';
import {useQuestions} from "@/utils/paper.js";
const { getQuestionById } = useQuestions()
const props = defineProps({
  questionId:{
    type: String
  }
});
const questionId=props.questionId;// 该题的id
const question=getQuestionById(questionId);// 根据Id查询题目
const getJumpInfo=(choiceValue)=>{
  // 获取jumpLogic数组
  const jumpLogicArray=question['ruleLogic']?.jumpLogic||[];
  // 遍历jumpLogic数组，检查每个对象的matchValue
  for (let logic of jumpLogicArray){
    if(logic.matchValue===choiceValue){
      return `跳转至${logic.targetQuestionId}题目`;
    }
  }
  // 如果没有匹配的，返回空字符串
  return ``;
}
</script>
